<?php
@header('Content-Type: text/html; charset=utf-8');
require_once('third/class.phpmailer.php');
require_once("third/class.smtp.php"); 

$svr_smtp_addr = "smtp.exmail.qq.com";
$svr_smtp_port = 465;
$svr_smtp_user = "service@dingyue.me";
$svr_smtp_passwd = "Kl84591789";
$svr_mail = "service@dingyue.me";
$svr_name = "爱订阅";

function send_mail($rcv, $subject, $html_msg)
{
  print_r(date("Y-m-d H:i:s")."\n");
  print_r("==========\n");
  print_r("rcv:$rcv\n");
  print_r("subject:$subject\n");
  print_r("html_msg:$html_msg\n");
  print_r("==========\n");

  global $svr_smtp_addr;
  global $svr_smtp_port;
  global $svr_smtp_user;
  global $svr_smtp_passwd;
  global $svr_mail;
  global $svr_name;

  $mail  = new PHPMailer(); 

  //设定邮件编码，默认ISO-8859-1，如果发中文此项必须设置为 UTF-8
  $mail->CharSet    ="UTF-8";
  // 设定使用SMTP服务
  $mail->IsSMTP();
  // 启用 SMTP 验证功能
  $mail->SMTPAuth   = true;
  // SMTP 安全协议
  $mail->SMTPSecure = "ssl";
  // SMTP 服务器
  $mail->Host       = $svr_smtp_addr;
  // SMTP服务器的端口号
  $mail->Port       = $svr_smtp_port;
  // SMTP服务器用户名
  $mail->Username   = $svr_smtp_user;
  // SMTP服务器密码
  $mail->Password   = $svr_smtp_passwd;
  // 设置发件人地址和名称
  $mail->SetFrom($svr_mail, $svr_name);
  // 设置邮件回复人地址和名称
  $mail->AddReplyTo($svr_mail, $svr_name); 
  // 设置邮件标题
  $mail->Subject    = $subject;
  // 设置邮件内容
  $mail->MsgHTML($html_msg);
  // 附件 
  //$mail->AddAttachment("images/phpmailer.gif");
  $mail->AddAddress($rcv, $rcv);

  if(!($bret = $mail->Send()))
  {
    echo "Send mail fail" . $mail->ErrorInfo . "\n";
  }
  return $bret;
}

//send_mail("yubai.lk@alipay.com", "hello likai", "test only");

?>
